##############################
# Judaism Flavor Events      #
#                            #
# Written by Roger Corominas #
# and Javier Salazar         #
##############################

namespace = jewish_flavor

#Passover
country_event = {
	id = jewish_flavor.1
	title = jewish_flavor.1.t
	desc = jewish_flavor.1.d
	picture = FEAST_eventPicture
	
	trigger = {
		religion = jewish
		is_month = 2 #March. Passover is at the end of March-beginning of April
		NOT = { is_month = 4 }
	}
	
	mean_time_to_happen = {
		months = 24
	}
	
	immediate = { set_country_flag = shalosh_regalim }
	
	option = {
		name = jewish_flavor.1.a
		if = {
			limit = {
				any_owned_province = { trade_goods = livestock }
			}
			custom_tooltip = passover_tooltip
			hidden_effect = {
				every_owned_province = {
					limit = { trade_goods = livestock }
					add_province_modifier = { 
						name = shalosh_regalim_modifier
						duration = 365
					}
				}
			}
		}
		else = {
			add_country_modifier = {
				name = passover_modifier
				duration = 365
			}
		}
	}
}

#Shavuot
country_event = {
	id = jewish_flavor.2
	title = jewish_flavor.2.t
	desc = jewish_flavor.2.d
	picture = FEAST_eventPicture
	
	trigger = {
		religion = jewish
		is_month = 4 #May. Shavuot is at the end of May-beginning of June
		NOT = { is_month = 6 }
	}
	
	mean_time_to_happen = {
		months = 24
	}

	immediate = { set_country_flag = shalosh_regalim }

	option = {
		name = jewish_flavor.2.a
		if = {
			limit = {
				any_owned_province = { trade_goods = grain }
			}
			custom_tooltip = shavuot_tooltip
			hidden_effect = {
				every_owned_province = {
					limit = { trade_goods = grain }
					add_province_modifier = {
						name = shalosh_regalim_modifier
						duration = 365
					}
				}
			}
		}
		else = {
			add_country_modifier = {
				name = shavuot_modifier
				duration = 365
			}
		}
	}
}

#Sukkot	
country_event = {
	id = jewish_flavor.3
	title = jewish_flavor.3.t
	desc = jewish_flavor.3.d
	picture = FEAST_eventPicture
	
	trigger = {
		religion = jewish
		is_month = 8 #September. Sukkot is at the end of September-beginning of October
		NOT = { is_month = 10 }
	}
	
	mean_time_to_happen = {
		months = 24
	}
	
	immediate = { set_country_flag = shalosh_regalim }

	option = {
		name = jewish_flavor.3.a
		add_country_modifier = {
			name = sukkot_modifier
			duration = 365
		}
	}
}

#Bar Mitzvah
country_event = {
	id = jewish_flavor.4
	title = jewish_flavor.4.t
	desc = jewish_flavor.4.desc
	picture = FEAST_eventPicture
	
	trigger = {
		religion = jewish
		government = monarchy
		OR = {
			AND = {
				has_female_heir = yes
				heir_age = 12
			}
			AND = {
				heir_age = 13
				NOT = { has_female_heir = yes }
			}
		}
		NOT = { heir_age = 14 }
		NOT = { has_country_flag = had_bmv }
	}
	
	mean_time_to_happen = { days = 1 }
	
	immediate = { set_country_flag = had_bmv }
	
	option = {#Spend lavishly
		name = jewish_flavor.4.a
		ai_chance = {
			factor = 25
			modifier = {
				factor = 2
				ruler_has_personality = drunkard_personality
			}
			modifier = {
				factor = 0
				ruler_has_personality = greedy_personality
			}
		}
		add_years_of_income = -1
		add_prestige = 20
		add_country_modifier = {
			name = lavish_bmv
			duration = 365		#Option to have these modifiers until heir gets to the throne?
		}
		add_estate_loyalty = {
			estate = estate_church
			loyalty = 15
		}
	}
	
	option = {#Do a normal celebration
		name = jewish_flavor.4.b
		ai_chance = {
			factor = 25
			modifier = {
				factor = 2
				ruler_has_personality = pious_personality
			}
		}
		add_years_of_income = -0.66
		add_prestige = 10
		add_country_modifier = {
			name = normal_bmv
			duration = 365		#Option to have these modifiers until heir gets to the throne?
		}
		add_estate_loyalty = {
			estate = estate_church
			loyalty = 10
		}
	}

	option = {#Be cheap
		name = jewish_flavor.4.c
		ai_chance = {
			factor = 25
			modifier = {
				factor = 2
				OR = {
					ruler_has_personality = greedy_personality
					ruler_has_personality = embezzler_personality
				}
			}
		}
		add_country_modifier = {
			name = cheap_bmv
			duration = 365		#Option to have these modifiers until heir gets to the throne?
		}
		add_years_of_income = -0.33
		add_estate_loyalty = {
			estate = estate_church
			loyalty = -5
		}
	}

	option = {#Do not celebrate
		name = jewish_flavor.4.d
		ai_chance = {
			factor = 25
			modifier = {
				factor = 2
				OR = {
					ruler_has_personality = greedy_personality
					ruler_has_personality = embezzler_personality
				}
			}
			modifier = {
				factor = 0
				ruler_has_personality = pious_personality
			}
		}
		add_country_modifier = {
			name = no_bmv
			duration = 365		#Option to have these modifiers until heir gets to the throne?
		}
		add_estate_loyalty = {
			estate = estate_church
			loyalty = -10
		}
		add_prestige = -20
	}
}

# The Third Temple
country_event = {
	id = jewish_flavor.5
	title = jewish_flavor.5.t
	desc = jewish_flavor.5.d
	picture = JUDAISM_TEMPLE_eventPicture
	
	major = yes
	fire_only_once = yes
	
	trigger = {
		religion = jewish
		379 = {
			owned_by = ROOT
			is_core = ROOT
			religion = jewish			
		}
	}
	
	mean_time_to_happen = {
		days = 1
	}
	
	option = { #We will build the Third Temple
		name = jewish_flavor.5.a
		ai_chance = {
			factor = 50
			modifier = {
				factor = 0
				NOT = {
					treasury = 4000
				}
			}
		}
		add_treasury = -4000
		add_prestige = 20
		hidden_effect = {
			379 = {
				set_province_flag = third_temple_built
			}
		}
		if = {
			limit = {
				has_dlc = "Origins"
			}
			add_church_power = 20
		}
		if = {
			limit = {
				has_dlc = "Leviathan"
			}
			set_great_project_tier_3 = {
				type = holy_city_jerusalem
			}
		}
		else = {
			palestine_area = {
				add_province_modifier = {
					name = "third_temple_provincial_modifier"
					duration = -1
				}
			}
			add_country_modifier = {
				name = "third_temple_country_modifier"
				duration = -1
			}
		}
		custom_tooltip = third_temple_consequences_tooltip
		hidden_effect = {
			every_country = { 
				limit = {
					religion_group = muslim
				}
				add_opinion = {
					who = ROOT
					modifier = destroyed_al_aqsa_opinion
				}
				add_casus_belli = {
					target = ROOT
					type = cb_insult
					months = 60
				}
			}
			every_owned_province = {
				if = {
					limit = {
						religion = ibadi
					}
				ibadi_rebels = 1
				}
				if = {
					limit = {
						religion = shiite
					}
				shiite_rebels = 1
				}
				if = {
					limit = {
						religion = sunni
					}
				sunni_rebels = 1
				}
			}
		}
	}

	option = { #We will build the Third Temple in a different location
		name = jewish_flavor.5.b
		ai_chance = {
			factor = 50
			modifier = {
				factor = 0
				NOT = {
					treasury = 5000
				}
			}
		}
		add_treasury = -5000
		add_prestige = 20
		add_estate_loyalty = {
			estate = estate_church
			loyalty = -30
		}
		hidden_effect = {
			379 = {
				set_province_flag = third_temple_built
			}
		}
		if = {
			limit = {
				has_dlc = "Origins"
			}
			add_church_power = 10
		}
		if = {
			limit = {
				has_dlc = "Leviathan"
			}
			set_great_project_tier_3 = {
				type = holy_city_jerusalem
			}
		}
		else = {
			palestine_area = {
				add_province_modifier = {
					name = "third_temple_provincial_modifier"
					duration = -1
				}
			}
			add_country_modifier = {
				name = "third_temple_country_modifier"
				duration = -1
			}
		}
	}
	
	option = { #It is not the moment
		name = jewish_flavor.5.c
		ai_chance = {
			factor = 50
		}
		if = {
			limit = {
				has_dlc = "Origins"
			}
			add_church_power = -10
		}
		add_estate_loyalty = {
			estate = estate_church
			loyalty = -10
		}
		add_estate_influence_modifier = {
			estate = estate_church
			influence = 10
			duration = 7300
			desc = estate_not_built_temple
		}
		add_stability_or_adm_power = yes
	}
}

# Embrace Judaism
province_event = {
	id = jewish_flavor.6
	title = jewish_flavor.6.t
	desc = jewish_flavor.6.d
	picture = JUDAISM_eventPicture
	goto = root

	trigger = {
		owner = {
			religion = jewish
		}
		OR = {
			religion_group = christian
			religion_group = muslim
		}
		is_core = ROOT
	}
	
	mean_time_to_happen = {
		months = 600
	}
	
	option = { #Welcome back
		name = jewish_flavor.6.a
		change_religion = jewish
	}
}

# An Important Matter in Sabbath
country_event = {
	id = jewish_flavor.7
	title = jewish_flavor.7.t
	desc = jewish_flavor.7.d
	picture = BANKRUPTCY_eventPicture

	trigger = {
		religion = jewish	
	}
	
	mean_time_to_happen = {
		months = 360
	}
	
	option = { #Sabbath must be respected
		name = jewish_flavor.7.a
		ai_chance = {
			factor = 50
		}
		trigger = {
			NOT = {
				OR = {
					ruler_has_personality = pious_personality
					ruler_has_personality = zealot_personality
					ruler_has_personality = free_thinker_personality
					ruler_has_personality = sinner_personality
				}
			}
		}
		add_adm_power = -50
		add_estate_loyalty = {
			estate = estate_church
			loyalty = 10
		}
		random = {
			chance = 25
			add_stability = -1
		}
	}

	option = { #Important matters come first
		name = jewish_flavor.7.b
		ai_chance = {
			factor = 50
		}
		trigger = {
			NOT = {
				OR = {
					ruler_has_personality = pious_personality
					ruler_has_personality = zealot_personality
					ruler_has_personality = free_thinker_personality
					ruler_has_personality = sinner_personality
				}
			}
		}
		add_adm_power = 100
		add_estate_loyalty = {
			estate = estate_church
			loyalty = -20
		}
	}
	
	option = { #Sabbath must be respected (Personality forced)
		name = jewish_flavor.7.c
		trigger = {
			has_dlc = "Rights of Man"
			OR = {
				ruler_has_personality = pious_personality
				ruler_has_personality = zealot_personality
			}
		}
		highlight = yes
		
		if = {
			limit = {
				has_dlc = "Origins"
			}
			add_church_power = 10
			add_estate_loyalty = {
				estate = estate_church
				loyalty = 10
			}
		}
		else = {
			add_estate_loyalty = {
				estate = estate_church
				loyalty = 15
			}
		}
		add_adm_power = -50
		random = {
			chance = 25
			add_stability = -1
		}
	}

	option = { #Important matters come first (Personality forced)
		name = jewish_flavor.7.e
		trigger = {
			has_dlc = "Rights of Man"
			OR = {
				ruler_has_personality = free_thinker_personality
				ruler_has_personality = sinner_personality
			}
		}
		highlight = yes

		add_adm_power = 100
		add_estate_loyalty = {
			estate = estate_church
			loyalty = -20
		}
		random = {
			chance = 25
			add_stability = 1
		}
	}
}

# The Messiah #Credits to Canute VII for his suggestion
country_event = {
	id = jewish_flavor.8
	title = jewish_flavor.8.t
	desc = jewish_flavor.8.d
	picture = JUDAISM_eventPicture

	trigger = {
		NOT = {
			has_country_flag = ruler_is_messiah
		}
		religion = jewish
		government = monarchy
		legitimacy = 90
		months_of_ruling = 240
		379 = {
			NOT = {
				owned_by = ROOT
			}
		}
	}
	
	mean_time_to_happen = {
		months = 120
		modifier = {
			factor = 0.5
			ruler_has_personality = pious_personality
		}
		modifier = {
			factor = 3
			ruler_has_personality = sinner_personality
		}
	}
	
	immediate = {
		hidden_effect = {
			set_country_flag = ruler_is_messiah
		}
	}
	
	option = {
		name = jewish_flavor.8.a
		ai_chance = {
			factor = 50
		}
		add_country_modifier = {
			name = "no_messiah_country_modifier"
			duration = 3650
		}
	}

	option = {
		name = jewish_flavor.8.b
		ai_chance = {
			factor = 50
		}
		if = {
			limit = {
				has_dlc = "Origins"
			}
			add_church_power = 10
		}
		379 = {
			add_claim = ROOT
		}
	}
}